home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / OOFILE / Buildable, limited OOFILE / OOFILE headers / oofrw.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-18  |  5.8 KB  |  207 lines  |  [TEXT/CWIE]

  1. #ifndef H_OOFRW
  2. #define H_OOFRW
  3. // COPYRIGHT 1994 A.D. Software, All rights reserved
  4.  
  5. // report-writer layer of OOFILE database
  6.  
  7. // NOTE inline definitions included at end of this header file
  8.  
  9. #include "oof2.hpp"
  10. #include "oofview.hpp"
  11.  
  12. class dbRepColWidths : public OOF_ExpandableLongArray {
  13. public:
  14. // construction
  15.     dbRepColWidths (const unsigned int defColWidth=20) :
  16.                             OOF_ExpandableLongArray(defColWidth) {};
  17. };
  18.  
  19.  
  20. class dbRepPageBreak : public OOF_ExpandableLongArray {
  21. public:
  22. // construction
  23.     dbRepPageBreak (const unsigned int breakPos=0xFFFF) :
  24.                             OOF_ExpandableLongArray(breakPos) {};
  25. };
  26.  
  27.  
  28. class dbRepOverRun : public dbClass{
  29.     public:
  30.         dbRepOverRun() :
  31.             OverRun(0),
  32.             DeleteMe(0) {};
  33.         ~dbRepOverRun() {};
  34.         
  35.         char* OverRun;
  36.         char* DeleteMe;
  37.         
  38.     private:
  39. };
  40.  
  41.  
  42. class dbRepLine : public dbClass {
  43.     public:
  44.         dbRepLine() :
  45.             mLine(0) {};
  46.         ~dbRepLine();
  47.     private:
  48.         dbRepLine(dbRepLine& rhs) { assert(0); };
  49.         void operator=(const dbRepLine& rhs) { assert(0); };
  50.     
  51.     public:
  52.         
  53.         void prepare();
  54.         void clear();
  55.         void drawNCharsAt(unsigned int hPos, char* theChars, unsigned int len);
  56.         void fillNCharsAt(unsigned int hPos, char theChar, unsigned int len);
  57.         void drawToStream(unsigned int hPos, unsigned int len, ostream& os);
  58.         
  59.     private:
  60.         char *mLine;        // owned                                    // for drawing onto
  61.         static unsigned int mWidth;        // size of horizontal line - given to us by dbRepPage
  62.  
  63.     friend class dbRep;
  64. };
  65.  
  66.  
  67. class dbRepSizer : public dbClass {
  68. public:
  69. // construction
  70.     dbRepSizer (const OOF_String& reportTitle, 
  71.                             const     unsigned int pageHeight=70, 
  72.                             const     unsigned int pageWidth=80, 
  73.                             const     unsigned int leftMargin=6, 
  74.                             const     unsigned int rightMargin=6, 
  75.                             const     unsigned int topMargin=1, 
  76.                             const     unsigned int bottomMargin=1, 
  77.                             const     unsigned int colSepWidth=2, 
  78.                             const     unsigned int blockVertSep=1
  79.                             ) :
  80.                             mReportTitle(reportTitle),
  81.                             mPageHeight(pageHeight),
  82.                             mPageWidth(pageWidth),
  83.                             mLeftMargin(leftMargin),
  84.                             mRightMargin(rightMargin),
  85.                             mTopMargin(topMargin),
  86.                             mBottomMargin(bottomMargin),
  87.                             mColSepWidth(colSepWidth),
  88.                             mBlockVertSep(blockVertSep) {};
  89.     
  90.     dbRepSizer (const char * reportTitle="", 
  91.                             const     unsigned int pageHeight=70, 
  92.                             const     unsigned int pageWidth=80, 
  93.                             const     unsigned int leftMargin=6, 
  94.                             const     unsigned int rightMargin=6, 
  95.                             const     unsigned int topMargin=1, 
  96.                             const     unsigned int bottomMargin=1, 
  97.                             const     unsigned int colSepWidth=2, 
  98.                             const     unsigned int blockVertSep=1
  99.                             ) :
  100.                             mReportTitle(reportTitle),
  101.                             mPageHeight(pageHeight),
  102.                             mPageWidth(pageWidth),
  103.                             mLeftMargin(leftMargin),
  104.                             mRightMargin(rightMargin),
  105.                             mTopMargin(topMargin),
  106.                             mBottomMargin(bottomMargin),
  107.                             mColSepWidth(colSepWidth),
  108.                             mBlockVertSep(blockVertSep)  {};
  109.  
  110. // setters for use in simulating keyword arguments
  111. // eg dbRep( dbRepSizer("Andy's Report").pageHeight(80).DefColWidth(12) );
  112.     
  113.     dbRepSizer& title(const OOF_String&);
  114.     dbRepSizer& title(const char*);
  115.     dbRepSizer& pageHeight(const unsigned int);
  116.     dbRepSizer& pageWidth(const unsigned int);
  117.     dbRepSizer& leftMargin(const unsigned int);
  118.     dbRepSizer& rightMargin(const unsigned int); 
  119.     dbRepSizer& topMargin(const unsigned int); 
  120.     dbRepSizer& bottomMargin(const unsigned int); 
  121.     dbRepSizer& colSepWidth(const unsigned int);
  122.     dbRepSizer& blockVertSep(const unsigned int);
  123.  
  124. // presentation    
  125.     
  126. private:
  127.     OOF_String mReportTitle;
  128.     unsigned int mPageHeight, mPageWidth, mLeftMargin, mRightMargin, mTopMargin, mBottomMargin;
  129.     unsigned int mColSepWidth;        // whitespace between columns
  130.     unsigned int mBlockVertSep;        // whitespace between records on columnar and blocks on pagewise
  131.  
  132.     friend class dbRep;
  133.     friend class dbRepPage;
  134. };
  135.  
  136.  
  137. class dbRepPage : public dbClass {
  138.     public:
  139.         dbRepPage();
  140.         ~dbRepPage();
  141.     private:
  142.         dbRepPage(dbRepPage& rhs) { assert(0); };
  143.         void operator=(const dbRepPage& rhs) { assert(0); };
  144.  
  145.     public:        
  146.         void draw(dbRepSizer Sizer, ostream& os);
  147.         void clearLines(unsigned int start, unsigned int end);
  148.         void endPage(ostream& os);
  149.         
  150.     private:
  151.          dbRepLine* mPageMap;                    // array of horizontal bands      // owned
  152.          unsigned int    mWidth;                    // width of valid lines
  153.          unsigned int mNumLines;                // number of prinatble lines
  154.          unsigned int mBodyStart;            // position of data area under header
  155.                                                                          //   to save redrawing the header
  156.          unsigned int mNumPages;                // number of physical pages
  157.          unsigned int* mFieldPos;            // starting position of each field    // owned
  158.                                                                          //   within each dbRepLine
  159.          dbRepPageBreak mPageBreak;            // starting position of each new page
  160.                                                                          //   within each dbRepLine
  161.          unsigned int* mPageStart;            // starting Row on page below Header    // owned
  162.  
  163.     friend class dbRep;
  164. };
  165.  
  166. class dbRep : public dbClass {
  167. public:
  168.     enum ReportStyles {pageWise, columnar};
  169. // construction
  170.     dbRep(const dbRepSizer& sizer, const dbView& fields, const ReportStyles style=columnar) :
  171.                 mSizer(sizer),
  172.                 mFields(fields),
  173.                 mReportStyle(style),
  174.                 mPage() {};
  175.     
  176.     dbRep(const dbRepSizer& sizer, dbRepColWidths colWidths, const dbView& fields, const ReportStyles style=columnar) :
  177.                 mSizer(sizer),
  178.                 mColWidths(colWidths),
  179.                 mFields(fields),
  180.                 mReportStyle(style),
  181.                 mPage() {};
  182.     
  183.     void setStyle(const ReportStyles);
  184.  
  185. // presentation    
  186.     void formatForCharStream();        // may be others later
  187.     unsigned int drawWrappedChars(unsigned int line,unsigned int hPos,unsigned int width,char **theString);
  188.     void drawColumnar(ostream&);
  189.     void drawPageWise(ostream&);
  190.     void drawHeader(ostream&);
  191.     void draw(ostream&);
  192.     void dumpFieldList(ostream&);
  193.     void extract(ostream&);
  194.     char *copyStr(char *theString);
  195.     
  196. private:
  197.     dbRepSizer    mSizer;
  198.     dbRepColWidths mColWidths;
  199.     dbView mFields;
  200.     ReportStyles mReportStyle;
  201.     dbRepPage mPage;
  202. };
  203.  
  204. // include inline definitions
  205. #include "oofrw.inl"
  206.  
  207. #endif